﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using  ThuVienCT;


namespace QLCTNA
{
    public partial class Frm_taomoi : Form
    {
        private ConnectionData cnn = null;
        public Frm_taomoi()
        {
            InitializeComponent();
            FileText ft = new FileText("Config\\Config.ini");

            this.MaximizeBox = false;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            cnn = Connection.Connect();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Frm_nguyenlieu nguyenlieu = new Frm_nguyenlieu();
            nguyenlieu.ShowDialog();

        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Frm_quytrinh quytrinh = new Frm_quytrinh();
            quytrinh.ShowDialog();
        }

        private void btntaomoicongthuc_Click(object sender, EventArgs e)
        {
            if (txtmacongthuc.Text == "" && txttencongthuc.Text == "" && txtloaicongthuc.Text == "")
            {
                MessageBox.Show("bạn phải nhập đầy đủ thông tin", "WARN!!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtmacongthuc.Focus();
            }
            else
            {
                string insert = null;
                int check = 0;
                if (cnn.Check())
                {
                    insert = " insert into vw_CongThuc([Mã Công Thức],[Tên Công Thức],[Phân Loại])" + "values({0},{1},{2});";
                    check = cnn.Execute(insert, txtmacongthuc.Text, txttencongthuc.Text, txtloaicongthuc.Text);
                    if (check > 0)
                    {
                        MessageBox.Show("Đã tạo mới công thức nấu ăn", "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                       
                    }
                    else
                    {
                        MessageBox.Show("khong them thanh cong", "thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                }

            }
        }

        private void txttencongthuc_TextChanged(object sender, EventArgs e)
        {

        }

        private void Frm_taomoi_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
